package com.example.demo1107.demo1;

public class Test {
    public static void main(String[] args) {
        Singleton instance = Singleton.getInstance();
        System.out.println("饿汉 = " + instance);
        Singleton instance1 = Singleton.getInstance();
        System.out.println("饿汉 = " + instance1);
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("懒汉 = " + Singleton01.getInstance());
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("懒汉 = " + Singleton01.getInstance());
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("加锁 = " + Singleton02.getInstance());
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("加锁 = " + Singleton02.getInstance());
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("双重锁 = " + Singleton03.getInstance());
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("双重锁= " + Singleton03.getInstance());
            }
        }).start();



    }
}
